<script setup>
	import FocusCommand from '../FocusCommand.vue'
	import {
		useTemplateRef,
		onMounted,
		ref
	} from 'vue'

	// 第一个参数必须与模板中的 ref 值匹配
	const input = useTemplateRef('my-input')

	const list = ref([1, 2, 3])

	const itemRefs = useTemplateRef('items')

	onMounted(() => {
		input.value.focus()
		alert(itemRefs.value.map(i => i.textContent))
	})
</script>

<template>
	<input ref="my-input" />
	<ul>
		<li v-for="item in list" ref="items">
			{{ item }}
		</li>
	</ul>
	<FocusCommand></FocusCommand>
</template>